package com.canto.wanna.user.controller;

import com.canto.common.controller.BaseController;
import com.canto.wanna.user.pojo.doo.UserDO;
import com.canto.wanna.user.pojo.query.UserQuery;
import com.canto.wanna.user.services.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import reactor.core.publisher.Mono;

import java.util.List;

@EnableWebSecurity// 开启springSecurity
@EnableGlobalMethodSecurity(securedEnabled = true)
@Controller
@RequestMapping(value = "/user")
@Api("用户管理")
public class UserController extends BaseController {

    @Autowired
    private UserService userService;

    @ApiOperation("用户信息")
    @Secured("user:user:view")
    @RequestMapping(value = "list")
    public Mono<List<UserDO>> list(UserQuery userQuery) {
        List<UserDO> list = userService.findList(userQuery);
        return Mono.just(list);
    }

}
